package com.sbl.bajw.pc.service;

import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Service;

import com.sbl.bajw.common.DbManager;

@Service
public class JWTMsgPushService {

	public void msgPush(String equipmentcode,String content) throws Exception{
		List<String> insertTaskParm = new ArrayList<String>();
		List<String> insertTaskItemParm = new ArrayList<String>();
		
		String getId = " select dgjwt.seq_sendtask.nextval@ysdblink from dual ";
		String taskId = DbManager.executeScalar(getId, null)+"";
		String insertTaskSql = "  insert into dgjwt.sendtask@ysdblink(taskid,taskcontent,posttime) "
				+ "	values('"+taskId+"',?,sysdate)";
		insertTaskParm.add(content);
		
		DbManager.executeUpdate(insertTaskSql, insertTaskParm);
		
		String insertTaskItemSql = " insert into dgjwt.sendnumber@ysdblink(taskid,numberid,equipmentcode)"
				+ " values('"+taskId+"',dgjwt.seq_sendnumber.nextval@ysdblink,?) ";
		insertTaskItemParm.add(equipmentcode);
		DbManager.executeUpdate(insertTaskItemSql, insertTaskItemParm);
		
		DbManager.commit();
	}
	
}
